package com.jia.product.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jia.product.entity.CategoryBrandRelation;
import com.jia.product.service.CategoryBrandRelationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 品牌分类关联(CategoryBrandRelation)表控制层
 *
 * @author makejava
 * @since 2025-07-08 18:15:26
 */
@RestController
@RequestMapping("category/brand/relation")
public class CategoryBrandRelationController {
    /**
     * 服务对象
     */
    @Resource
    private CategoryBrandRelationService categoryBrandRelationService;


    /**
     * 获取品牌下的分类信息
     */
    @GetMapping("/category/list")
    public List<CategoryBrandRelation> queryCategoryByBrandId(@RequestParam Long brandId) {
        QueryWrapper<CategoryBrandRelation> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("brand_id", brandId);
        return categoryBrandRelationService.list(queryWrapper);
    }


    /**
     * 新增品牌分类关联
     *
     * @param categoryBrandRelation 关联实体
     * @return 实例对象
     */
    @PostMapping("/save")
    public CategoryBrandRelation saveCategoryBrandRelation(@RequestBody CategoryBrandRelation categoryBrandRelation) {
        return categoryBrandRelationService.saveRelation(categoryBrandRelation);
    }


}

